package org.codeCard.control;

import org.codeCard.bean.SearchSaleCardResultBean;
import org.codeCard.frame.CodeCardJFrame;
import org.codeCard.panel.CodeCardBuyJPanel;
import org.codeCard.panel.CodeCardJPanel;
import org.codeCard.util.CodeCardUntil;
import org.come.action.FromServerAction;
import org.come.until.GsonUtil;

public class SaleCardSearchControl implements FromServerAction {
    @Override
    public void controlMessFromServer(String mes, String type) {
        try {
            // 消息处理部分
            SearchSaleCardResultBean sa = GsonUtil.getGsonUtil().getgson().fromJson(mes, SearchSaleCardResultBean.class);

            CodeCardJPanel bjczCardJpanel = CodeCardJFrame.getBjczMainJpanel().getBjczCardJpanel();

            CodeCardBuyJPanel bjcz1Jpanel = bjczCardJpanel.getBjcz1Jpanel();
            CodeCardUntil.setBuyTableModel(bjcz1Jpanel.getjScrollPane(), sa.getSaleCardOrders());

            bjcz1Jpanel.setPage(
                    sa.getTotal() == 0 ? 1 : sa.getTotal());

            CodeCardJFrame.bjczMainJpanel.getBjczCardJpanel().getCardLayout()
                    .show(CodeCardJFrame.bjczMainJpanel.getBjczCardJpanel(), "bjcz1Jpanel");

        } catch (Exception e) {

        }
    }
}
